home *** CD-ROM | disk | FTP | other *** search
/ ftp.cs.arizona.edu / ftp.cs.arizona.edu.tar / ftp.cs.arizona.edu / icon / newsgrp / group96a.txt / 000139_icon-group-sender _Tue Jun 18 13:09:09 1996.msg < prev    next >
Internet Message Format  |  1996-09-05  |  2KB

  1. Received: by cheltenham.cs.arizona.edu; Tue, 18 Jun 1996 13:13:57 MST
  2. X-Sender: nevin@192.12.69.186
  3. Message-Id: <v02140b00adecbab40584@[150.135.1.79]>
  4. Mime-Version: 1.0
  5. Content-Type: text/plain; charset="us-ascii"
  6. Date: Tue, 18 Jun 1996 13:09:09 -0700
  7. To: "Icon Group" <icon-group@cs.arizona.edu>
  8. From: nevin@cs.arizona.edu (Nevin ":-]" Liber)
  9. Subject: Re: Locking files
  10. Errors-To: icon-group-errors@cs.arizona.edu
  11. Status: O
  12.  
  13. At 5:11 AM 6/18/96, Hamish Lawson wrote:
  14.  
  15. > Jerzy Karczmarczuk wrote:
  16.  
  17. > > there is a cheap way of locking something
  18. > > globally used for ages: the *creation* of a special "lock" file
  19. > > just before entering the critical section (if it is absent,
  20. > > otherwise sleep/wait), and the destruction after.
  21.  
  22. > Is there not a small risk that in the time between some process finding
  23. > that the lock file doesn't exist and creating this file, another process
  24. > might also find that the lock file doesn't exist, thereby breaking the
  25. > exclusivity mechanism.
  26.  
  27. Under Unix (this stuff is OS dependent, making it difficult to abstract
  28. away in a high level language), opening a file is an atomic operation.  If
  29. you are programming in C, you can set the flags during open to create a
  30. file if and only if it does not already exist, making it a very expensive
  31. but fully functional TestAndSet instruction (basic primitive needed to
  32. implement semaphores).  However, there does not appear to be a way to get
  33. at this mechanism from Icon itself.
  34.  
  35. --
  36.         Nevin ":-)" Liber       nevin@CS.Arizona.EDU    (520) 293-2799
  37.                                 http://www.cs.arizona.edu/people/nevin/
  38.  
  39.  
  40.